AS=/usr/local/mips-cross/bin/mipsel-elf-as
CC=/usr/local/mips-cross/bin/mipsel-elf-gcc
LD=/usr/local/mips-cross/bin/mipsel-elf-ld
OBJCOPY=/usr/local/mips-cross/bin/mipsel-elf-objcopy
OBJDUMP=/usr/local/mips-cross/bin/mipsel-elf-objdump

CFLAGS=-mips1 -fomit-frame-pointer -nodefaultlibs -nostartfiles -nostdlib -membedded-data -mno-mips16 -fno-builtin -g --std=c99

INCLUDE=-I../../include/

all:
	$(CC) coremark.c -c $(CFLAGS) $(INCLUDE) -o coremark.o 
	$(AS) -mips1 bootloader.S -o bootloader.o -EL -g
	$(LD) -mips1 -T ../../lib/default.ld coremark.o bootloader.o -o coremark.elf -EL -g
	$(OBJCOPY) -j .startup.bootvec -j .startup -j .rodata -O binary coremark.elf coremark.bin
	hexdump -e "1/4 \"%08x\n\"" coremark.bin -v > coremark.hex

dump:
	$(OBJDUMP) -j .startup.bootvec -j .startup -S -D coremark.elf -z

symbols:
	$(OBJDUMP) -t coremark.elf

sections:
	$(OBJDUMP) -h coremark.elf

clean:
	rm -f coremark.bin coremark.elf coremark.hex coremark.o bootloader.o
